package world;


public class ChunkBlock {
	//public final static float SIZE=1.0F;
	public final static float SIZE=1.0f;
	private Vertex[] vertexes = new Vertex[24];
	private float xl, yl, zl,xh, yh, zh;	
	public static int VERTEX_PER_FACE=4;
	public int blockID;

	public ChunkBlock(int blockID,float x, float y, float z) {
		this.blockID = blockID;
		this.xl = x;
		this.yl = y;
		this.zl = z;
		this.xh = x + SIZE;
		this.yh = y + SIZE;
		this.zh = z + SIZE;
	}
	
	public void createVertexes(){
		int i = 0;	
		//front
		vertexes[i++] = new Vertex().setXYZ(xl, yl, zh).setRGB(0, 1, 0).setST(0, 1);// left bottom
		vertexes[i++] = new Vertex().setXYZ(xh, yl, zh).setRGB(0, 0, 1).setST(1, 1);// right bottom
		vertexes[i++] = new Vertex().setXYZ(xh, yh, zh).setRGB(1, 1, 1).setST(1, 0);// right top		
		vertexes[i++] = new Vertex().setXYZ(xl, yh, zh).setRGB(1, 0, 0).setST(0, 0);// left top

		// top
		vertexes[i++] = new Vertex().setXYZ(xl, yh, zl).setRGB(1, 1, 1).setST(0, 0);// right top
		vertexes[i++] = new Vertex().setXYZ(xh, yh, zl).setRGB(0, 0, 1).setST(1, 0);// right bottom	
		vertexes[i++] = new Vertex().setXYZ(xh, yh, zh).setRGB(0, 1, 0).setST(1, 1);// left bottom
		vertexes[i++] = new Vertex().setXYZ(xl, yh, zh).setRGB(1, 0, 0).setST(0, 1);// left top
		
		// right
		vertexes[i++] = new Vertex().setXYZ(xh, yl, zh).setRGB(1, 0, 0).setST(0, 1);// left top
		vertexes[i++] = new Vertex().setXYZ(xh, yl, zl).setRGB(0, 1, 0).setST(1, 1);// left bottom
		vertexes[i++] = new Vertex().setXYZ(xh, yh, zl).setRGB(0, 0, 1).setST(1, 0);// right bottom
		vertexes[i++] = new Vertex().setXYZ(xh, yh, zh).setRGB(1, 1, 1).setST(0, 0);// right top

		// back
		vertexes[i++] = new Vertex().setXYZ(xh, yl, zl).setRGB(1, 0, 0).setST(0, 1);// left top
		vertexes[i++] = new Vertex().setXYZ(xl, yl, zl).setRGB(0, 1, 0).setST(1, 1);// left bottom
		vertexes[i++] = new Vertex().setXYZ(xl, yh, zl).setRGB(0, 0, 1).setST(1, 0);// right bottom
		vertexes[i++] = new Vertex().setXYZ(xh, yh, zl).setRGB(1, 1, 1).setST(0, 0);// right top
		
		// left
		vertexes[i++] = new Vertex().setXYZ(xl, yl, zl).setRGB(1, 0, 0).setST(0, 1);// left top
		vertexes[i++] = new Vertex().setXYZ(xl, yl, zh).setRGB(0, 1, 0).setST(1, 1);// left bottom
		vertexes[i++] = new Vertex().setXYZ(xl, yh, zh).setRGB(0, 0, 1).setST(1, 0);// right bottom
		vertexes[i++] = new Vertex().setXYZ(xl, yh, zl).setRGB(1, 1, 1).setST(0, 0);// right top
	
		// bottom
		vertexes[i++] = new Vertex().setXYZ(xl, yl, zl).setRGB(1, 0, 0).setST(0, 1);// left top
		vertexes[i++] = new Vertex().setXYZ(xh, yl, zl).setRGB(0, 1, 0).setST(1, 1);// left bottom
		vertexes[i++] = new Vertex().setXYZ(xh, yl, zh).setRGB(0, 0, 1).setST(1, 0);// right bottom
		vertexes[i++] = new Vertex().setXYZ(xl, yl, zh).setRGB(1, 1, 1).setST(0, 0);// right top
	}
	
	public Vertex[] getVertexes(){
		return vertexes;
	}

}
